﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Index.aspx.cs" Inherits="Web.Views.Index" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script src="../js/jquery-1.8.2.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">
    <div id="NavSecd">
        <div>
            <div style="width: 100%;">
                <table class="tbform" style="width: 95%; margin-left: auto; margin-right: auto; text-align: left;">
                    <tr>
                        <td style="height: 10px;">
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 120px;">
                            
                        </td>
                        <td>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>
                            
                        </td>
                        <td>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>
                            
                        </td>
                        <td>
                           
                        </td>
                    </tr>
                    <tr>
                        <td>
                            
                        </td>
                        <td>
                            
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            
                        </td>
                    </tr>
                    <tr>
                        <td style="height: 10px;">
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <table id="list" class="scroll">
                            </table>
                            <div id="listPager" class="scroll" style="text-align: center;">
                            </div>
                            <div id="listPsetcols" class="scroll" style="text-align: center;">
                            </div>
                        </td>
                    </tr>
                    <tr>
                    </tr>
                    <tr>
                        <td colspan="2">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Footer" runat="server">
    <script type="text/javascript">

        $(document).ready(function () {
            callHandler();
        });

        //-------------------------------------------------

        function callHandler() {
            $.ajax({
                url: "Handlers/IndexHandler.ashx",
                type: "post",
                success: function (data) {
                    alert(data);
                }
            });
        }

        function initialGrid() {

            var updateDialog = {
                url: '/RemarkMaster/Update'
                , closeAfterAdd: true
                , closeAfterEdit: true
                , afterShowForm: function (formId) {
                    $("#REJECT_CODE").blur(function () {
                        ajaxDupBinding("#REJECT_CODE", $(this).val())
                    });

                    if ($("#REJECT_CODE").val() == '') {
                        getNextCode("#REJECT_CODE");
                    }
                }
                , afterclickPgButtons: function (whichbutton, formid, rowid) {

                }
                , modal: true

                , onclickSubmit: function (params) {
                    var ajaxData = {};

                    var list = $("#list");
                    var selectedRow = list.getGridParam("selrow");
                    rowData = list.getRowData(selectedRow);
                    ajaxData = { REJ_REMARK_ID: rowData.REJ_REMARK_ID };

                    return ajaxData;
                }

                , width: "450"
            };

            $.jgrid.nav.addtext = "";
            $.jgrid.nav.edittext = "";
            $.jgrid.nav.deltext = "";
            $.jgrid.edit.addCaption = "@RemarkMaster.REJECT_ADD_CAPTION";
            $.jgrid.edit.editCaption = "@RemarkMaster.REJECT_EDIT_CAPTION";
            $.jgrid.del.caption = "@RemarkMaster.REJECT_DEL_CAPTION";
            $.jgrid.del.msg = "@RemarkMaster.REJECT_DEL_MSG";

            $("#list").jqGrid({
                datatype: 'json',
                mtype: 'POST',
                colNames: ['ID', '@RemarkMaster.REJECT_GROUP_CODE', '@RemarkMaster.REJECT_SUB_GROUP_CODE', '@RemarkMaster.REJECT_CODE', '@RemarkMaster.REJECT_NAME_TH', '@RemarkMaster.REJECT_NAME_EN', '@RemarkMaster.DISPLAY_ORDER'],
                colModel: [
                    { name: 'REJ_REMARK_ID', index: 'REJ_REMARK_ID', width: 40, align: 'left', key: true, editable: true, editrules: { edithidden: false }, hidedlg: true, hidden: true },
                    { name: 'REJECT_GROUP_CODE', index: 'REJECT_GROUP_CODE', width: 40, align: 'left', editable: true, edittype: "select", editoptions: { dataUrl: "/RemarkMaster/GroupSelectList" }, editrules: { edithidden: true }, hidedlg: true, hidden: true },
                    { name: 'REJECT_SUB_GROUP_CODE', index: 'REJECT_SUB_GROUP_CODE', width: 40, align: 'left', editable: true, edittype: "select", editoptions: { dataUrl: "/RemarkMaster/SubGroupSelectList" }, editrules: { edithidden: true }, hidedlg: true, hidden: true },
                    { name: 'REJECT_CODE', index: 'REJECT_CODE', width: 30, align: 'left', editable: true, edittype: 'text', editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
                    { name: 'REJECT_NAME_TH', index: 'REJECT_NAME_TH', width: 280, align: 'left', editable: true, edittype: 'text', editrules: { required: true }, formoptions: { elmsuffix: ' *' }, editoptions: { size: 20} },
                    { name: 'REJECT_NAME_EN', index: 'REJECT_NAME_EN', width: 280, align: 'left', editable: true, edittype: 'text', editrules: { required: true }, formoptions: { elmsuffix: ' *' }, editoptions: { size: 20} },
                    { name: 'DISPLAY_ORDER', index: 'DISPLAY_ORDER', width: 40, align: 'left', formatter: 'integer', editable: true, edittype: "text", editrules: { edithidden: true, required: true }, formoptions: { elmsuffix: ' *' }, editoptions: { size: 5}}],
                pager: $('#listPager'),
                rowNum: 10,
                rowList: [10, 20, 30],
                height: 250,
                rownumbers: true,
                sortname: 'REJECT_CODE',
                sortorder: "asc",
                viewrecords: true,
                imgpath: '/Content/Themes/Redmond/Images',
                caption: '@RemarkMaster.REJECT_TABLE_TITLE',
                autowidth: true,
                ondblClickRow: function (rowid, iRow, iCol, e) {
                    alert("selected");

                }
            }).navGrid('#listPager',
                {
                    edit: true, add: true, del: true, search: false, refresh: true
                },
                updateDialog,
                updateDialog,
                updateDialog
            );
        }

        function doClearForm() {

            $("#rejectGroup").val("");
            $("#rejectSubGroup").val("");
            $("#REJECT_NAME_TH").val("");
            $("#REJECT_NAME_EN").val("");

            $('#list').jqGrid('clearGridData');
            //$('#list').setGridParam({postData: null}).trigger('reloadGrid');
        }

        function doSaveLineEdit(value) {
            if (confirm("Do you want to save?")) {
                $('#RemarkGrid').saveRow(value);
            }
        }

        function BindGrid() {
            var params = {
                group: $("#rejectGroup").val(),
                subGroup: $("#rejectSubGroup").val(),
                keywordth: $("#REJECT_NAME_TH").val(),
                keyworden: $("#REJECT_NAME_EN").val()
            };

            $('#list').setGridParam({ url: '/RemarkMaster/List', postData: params }).trigger('reloadGrid');
        }

</script>

</asp:Content>
